package com.pur.zsms.common.support;

import javax.persistence.LockModeType;

/**
 * <p>Lock mode被lock方法使用。</p>
 * <p>READ模式保证避免dirty read和non-repeated read。WRITE模式使得entity的version字段增长。</p>
 * <p>Create Time: 2008-10-27</p>
 * @author wangzg002
 *
 */
public final class JpaLockMode {
	/**
	 * 读模式
	 */
	public static final JpaLockMode READ;

	/**
	 * 写模式
	 */
	public static final JpaLockMode WRITE;

	/**
	 *JPA的锁模式实例 
	 */
	private LockModeType lockModeType;

	/**私有构造函数,不允许修改
	 * @param modeType
	 */
	private JpaLockMode(LockModeType modeType) {
		lockModeType = modeType;
	}

	// 内部静态块,初始化读写模式
	static {
		READ = new JpaLockMode(LockModeType.READ);
		WRITE = new JpaLockMode(LockModeType.WRITE);

	}

	/**获取jpa的锁模式实例
	 * @return  锁模式实例
	 */
	public LockModeType getLockModeType() {
		return lockModeType;
	}

}
